import axios from "@/utils/http";

export function sendCopc() {
  // 360归因
  if (sessionStorage.getItem("qhclickid")) {
    // console.log("360归因");
    axios("https://api.szcits.cn/so360.ocpc/upload", {
      params: {
        event: "ADVISORY_BUTTON", //类别
        qhclickid: sessionStorage.getItem("qhclickid"), //点击id
        data_industry: "ocpc_ps_convert",
      },
    });
    // 删除 qhclickid
    sessionStorage.removeItem("qhclickid");
  }

  // 百度归因
  else if (sessionStorage.getItem("bd_vid")) {
    // console.log("百度归因");

    axios("https://api.szcits.cn/baidu.ocpc/upload", {
      params: {
        url: window.location.origin,
        bd_vid: sessionStorage.getItem("bd_vid"), //点击id
      },
    });
    // 删除 qhclickid
    sessionStorage.removeItem("bd_vid");
  }
}

// 目的地列表
export function line_items(data) {
  const token = localStorage.getItem("token");
  let obj = token ? { ...data, token } : data;
  return axios({
    method: "post",
    url: "line_items",
    data: {
      // token:token || null,
      ...obj,
    },
  });
}

/* 目的地详情 id: 线路area */
export function area_details(data) {
  return axios({
    method: "post",
    url: "area.index/details2",
    // url: 'area_items',
    data,
  });
}

// 区域目的地 fid（国内2，出境1）
export function destination_area(fid = 2) {
  return axios({
    method: "post",
    url: "area.destination/items",
    data: {
      fid,
    },
  });
}

/* 根据目的地id得到区域信息 id: 线路area */
export function area_Destination(data) {
  return axios({
    method: "post",
    url: "area.destination/getDestinationByArea",
    data,
  });
}
/* 根据目的地id得到同级列表 id: 线路des */
export function itemsByDestinationID(data) {
  return axios({
    method: "post",
    url: "area.destination/itemsByDestinationID",
    data,
  });
}

/* 主题游列表 limit: 每页长度 */
export function theme_items(data) {
  return axios({
    method: "post",
    url: "theme_items",
    data,
  });
}

/* 目的地主题游列表 area: 单个或多个（逗号分割） */
export function theme_itemsByArea(data) {
  return axios({
    method: "post",
    url: "theme.index/itemsByArea",
    data,
  });
}

// 玩法列表
export function connect_items(data) {
  return axios({
    method: "post",
    url: "area.connect/items",
    data,
  });
}

/* 图片宣传列表 id: 22 */
export function disseminate_items(data) {
  return axios({
    method: "post",
    url: "disseminate.index/items",
    data,
  });
}

/* detail */
// 商品详情
export function line_details(data) {
  return axios({
    method: "post",
    url: "line.index/details2",
    data,
  });
}
// 套餐列表
export function line_Packages(data) {
  return axios({
    method: "post",
    url: "line.Packages/items",
    data,
  });
}
// 团期列表
export function line_Dates(data) {
  return axios({
    method: "post",
    url: "line.Dates/items",
    data,
  });
}
// 团体价格/定制团
export function line_packages_groups(data) {
  return axios({
    method: "post",
    url: "line.packages/groups",
    data,
  });
}

// 天数安排 行程
export function line_Days(data) {
  return axios({
    method: "post",
    url: "line.Days/items",
    data,
  });
}

// 套餐价格
export function groups(data) {
  return axios({
    method: "post",
    url: "line.packages/groups",
    data,
  });
}

/* 旅游商品相关推荐
  参数: areas type limit
  type 默认：相关产品；
          1：特价产品；
          2：主推产品；
          3：周边产品
*/
export function getListOther(data) {
  // const token = uni.getStorageSync('token')
  // let obj = token ? {...data,token} : data
  return axios({
    method: "post",
    url: "line.index/getListOther",
    data: {
      // ...obj
      ...data,
    },
  });
}

/* 定制服务 提交客户需求 表单
 member.enquire/create
tel 手机号(必填)
type 类型 (私人定制、商品详情、商品定制)
question  目的地、商品名称、客户留言
p_id 商品id
nums 人数
days 天数
set_out 出发日期
 */
export function other_demand_add(obj) {
  return axios({
    method: "post",
    url: "other.demand/add",
    data: {
      ...obj,
      // 渠道
      type2: "h5",
    },
  });
}

/* 首页 index */
// 首页轮播图
export function index_banner(data) {
  return axios({
    method: "post",
    url: "disseminate.index/items",
    data,
  });
}

/* 主题游 */
// 主题游列表 ids:指定类别 / limit:显示pro内数量
export function theme_lists(data) {
  return axios({
    method: "post",
    url: "theme.lists/items",
    data,
  });
}

// 主题相关城市
export function get_areas_list_theme(data) {
  return axios({
    method: "post",
    url: "area.index/getareaslistbytheme",
    data,
  });
}

// 主题详情
export function theme_details(data) {
  return axios({
    method: "post",
    url: "theme.index/details",
    data,
  });
}

/* 狼性团建 */
/* 团建内容列表
  ctype 团建方案:69，主题类型:70，项目类型:71，场地类型:72
  type1 主题类型id
  type2 项目类型id
  type3 场地类型id
  pages 当前页面:1
  limit 每页显示条数:10

*/
export function group_items(data) {
  return axios({
    method: "post",
    url: "group.index/items",
    data,
  });
}

// 团建内容详情 id:产品id
export function group_details(data) {
  return axios({
    method: "post",
    url: "group.index/details",
    data,
  });
}

/* 国内游 */

/* 签证 */
// 国家列表 亚洲49，欧洲2，中东非51，美洲7，澳洲50
export function visa_country(type) {
  return axios({
    method: "post",
    url: "visa_countrys",
    data: {
      type,
      limit: 1000,
    },
  });
}

// 签证列表
export function visa_items(data) {
  return axios({
    method: "post",
    url: "visa.IndexSecond/items",
    // url: "/visa.index/items2",
    data: {
      area: 42,
      ...data,
    },
  });
}

// 签证详情
export function visa_details(data) {
  return axios({
    method: "post",
    url: "/visa.IndexSecond/details",
    // url: "/visa.index/details2",
    data,
  });
}

// 签证详情-有效人群
export function visa_peoples(data) {
  return axios({
    method: "post",
    url: "/visa.IndexSecond/peoples",
    // url: "/visa.index/peoples2",
    data,
  });
}

// 签证资料-指定人群
export function visa_data(data) {
  return axios({
    method: "post",
    url: "/visa.IndexSecond/datas",
    // url: "/visa.index/datas3",
    data,
  });
}

// 签证详情-有效类别
export function visa_types(data) {
  // console.log(data)
  return axios({
    method: "post",
    url: "/visa.IndexSecond/types",
    // url: "/visa_types",
    // url: "/visa.index/types2",
    data,
  });
}

// 签证详情-常驻地
export function visa_areas(data) {
  return axios({
    method: "post",
    url: "/visa_areas",
    data,
  });
}

// 签证详情-有效入境次数
export function visa_nums(data) {
  return axios({
    method: "post",
    url: "/visa.IndexSecond/nums",
    // url: "/visa_nums",
    data,
  });
}
// 线路搜索
export function search_index(data) {
  return axios({
    method: "post",
    url: "/search.index",
    data,
  });
}
// 线路搜索
export function search_visa(data) {
  return axios({
    method: "post",
    url: "/search.visas",
    data,
  });
}

// 发送短信验证码
export function sendCode(data) {
  return axios({
    method: "post",
    // url: "/sms_index",
    url: "/sms.index/index2",
    data: {
      phone: data.phone, //手机号
      template: data.template, //短信模板
      sign: data.sign, //签名
    },
  });
}
// 手机号登录
export function login(data) {
  return axios({
    method: "post",
    url: "/member.index/login2",
    data,
  });
}

// 会员详情
export function member_details() {
  const token = localStorage.getItem("token");
  if (!token) {
    return { data: {} };
  }
  return axios({
    method: "post",
    url: "/member.index/details2",
    data: {
      token,
    },
  });
}
